<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%String path = request.getContextPath();%>
<script type="text/javascript">
function submitSelectForm(form){
	if('${searchType}'=='')
		return navTabSearch(form);
	else
		return dwzSearch(form, 'dialog');
}
</script>
<form id="pagerForm" method="post" action="<%=path%>/active/listActive.action">
	<input type="hidden" name="pageRequest" value="1" />
	<input type="hidden" name="pageNum" value="${paginator.pageIndex}" />
	<input type="hidden" name="numPerPage" value="${paginator.pageSize}" />
</form>
<div class="pageHeader">
	<div class="searchBar">
		<form onsubmit="return submitSelectForm(this);" rel="pagerForm" action="<%=path%>/active/listActive.action" method="post">
			<input type="hidden" name="searchType" value="${searchType}"/>
			<ul class="searchContent">
				<li>
					<label style="text-align: right;">活动标题：</label>
					<input type="text" name="activeVO.title" value='<s:property value="activeVO.title"/>'/>
				</li>
				<li>
					<label style="text-align: right;">活动状态：</label>
					<select name="activeVO.state" class="combox">
						<option value="">所有活动</option>
						<option value="0"${activeVO.state==0?" selected='true'":""}>进行中</option>
						<option value="1"${activeVO.state==1?" selected='true'":""}>已停止</option>
					</select>
				</li>
				<c:choose>
					<c:when test="${SESSION_USER.customer==null}">
						<input name="activeVO.customerId" value="<s:property value="activeVO.customer.id" />" type="hidden">
						<c:if test="${searchType==null||searchType==''}">
							<li>
								<label style="text-align: right;">所属商家：</label>
								<input name="activeVO.customerName" onclick="$('#active_list_a_btnLook').click();" style="cursor: pointer;float: left;" value="<s:property value="activeVO.customerName" />">
								<!-- <a class="btnLook" id="active_list_a_btnLook" href="<%=path%>/customer/listCustomer.action?searchType=favourableEntity" lookupGroup="activeVO">选择</a> -->
							</li>
						</c:if>
					</c:when>
					<c:otherwise>
						<input name="activeVO.customerId" value="${SESSION_USER.customer.id}" type="hidden">
					</c:otherwise>
				</c:choose>
			</ul>
			<ul class="searchContent">
				<li>
					<label style="text-align: right;">发布日期：</label>
					从<input type="text" name="activeVO.startIssueDate" class="date" readonly="true" value="${activeVO.startIssueDate}" size="10"/>
					到<input type="text" name="activeVO.endIssueDate" class="date" readonly="true" value="${activeVO.endIssueDate}" size="10"/>
				</li>
				<li style="width:450px">
					<label style="text-align: right;">活动时间：</label>
					从<input type="text" name="activeVO.startTime" value="<s:date format="yyyy-MM-dd HH:mm:ss" name="activeVO.startTime"/>" class="date" dateFmt="yyyy-MM-dd HH:mm:ss" readonly="true" size="19"/>
					到<input type="text" name="activeVO.endTime" value="<s:date format="yyyy-MM-dd HH:mm:ss" name="activeVO.endTime"/>" class="date" dateFmt="yyyy-MM-dd HH:mm:ss" readonly="true" size="19"/>
				</li>
			</ul>
			<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">查询</button></div></div></li>
			</ul>
			</div>
		</form>
	</div>
</div>
<div class="pageContent">
<c:if test="${searchType==null||searchType==''}">
	<div class="panelBar">
		<ul class="toolBar">
			<shiro:hasPermission name="addActive">
			<li><a class="add" href="<%=path%>/active/addActive.action" target="navTab" title="添加活动"><span>添加</span></a></li>
			</shiro:hasPermission>
			<shiro:hasPermission name="deleteActives">
			<li><a title="确实要删除这些记录吗?" target="selectedTodo" rel="ids" postType="string" href="<%=path%>/active/deleteActives.action" class="delete"><span>删除</span></a></li>
			</shiro:hasPermission>
		</ul>
	</div>
</c:if>
	<table class="table" width="100%" layoutH="164">
		<thead>
			<tr><c:if test="${searchType==null||searchType==''}">
				<th width="2%"><input type="checkbox" group="ids" class="checkboxCtrl"></th>
				</c:if>
				<th width="10%">活动标题</th>
				<th width="6%">活动图片</th>
				<th width="10%">活动商家</th>
				<th width="12%">开始时间</th>
				<th width="12%">结束时间</th>
				<th width="5%">状态</th>
				<th>活动描述</th>
				<th width="5%">排序值</th>
				<th width="4%">置顶</th>
				<th width="5%">添加者</th>
				<th width="13%">添加时间</th>
				<th width="7%">操作</th>
			</tr>
		</thead>
		<tbody>
			<s:iterator value="activeList" id="active">
				<tr rel="<s:property value="id"/>">
					<c:if test="${searchType==null||searchType==''}">
					<td><input name="ids" value="<s:property value="id"/>" type="checkbox"></td>
					</c:if>
					<td title="${title}">${title}</td>
					<td><a href="<%=path%>/jsp/common/preview_image.jsp?folder=active&picNames=${picName}&id=${id}" target="dialog" rel="activeList" max="true" title="活动图片" width="800" height="480">查看图片</a></td>
					<td title="${customer.name}">${customer.name}</td>
					<td title="<s:date format="yyyy-MM-dd HH:mm:ss" name="startTime"/>"><s:date format="yyyy-MM-dd HH:mm:ss" name="startTime"/></td>
					<td title="<s:date format="yyyy-MM-dd HH:mm:ss" name="endTime"/>"><s:date format="yyyy-MM-dd HH:mm:ss" name="endTime"/></td>
					<td><s:if test="endTime.getTime()>=new java.util.Date().getTime()">进行中</s:if><s:else><a style="color:red">已到期</a></s:else></td>
		            <td title="${description}">${description}</td>
		            <td>${active.top}</td>
		            <td>
		             <shiro:hasPermission name="updateTopActive">
		             	<a title="您确定要置顶该活动吗？置顶将优先显示！" target="ajaxTodo" href="<%=path%>/active/updateTopActive.action?activeVO.id=${id}">置顶</a>
		             </shiro:hasPermission>
		             </td>
		             <td><s:property value="user.name"/></td>
		             <td><s:date format="yyyy-MM-dd HH:mm:ss" name="addTime"/></td>
					<c:if test="${searchType==null||searchType==''}">
					<td>
						<shiro:hasPermission name="deleteActive">
						<a title="确实要删除这条记录吗?" target="ajaxTodo" href="<%=path%>/active/deleteActive.action?activeVO.id=<s:property value="id"/>" class="btnDel">删除</a>
						</shiro:hasPermission>
						<shiro:hasPermission name="editActive">
						<a title="编辑" target="navTab" href="<%=path%>/active/editActive.action?activeVO.id=<s:property value="id"/>" class="btnEdit">编辑</a>
						</shiro:hasPermission>
					</td>
					</c:if>
					<c:if test="${searchType=='advertising'}">
						<td><a class="btnSelect" href="javascript:$.bringBack({linkId:'${id}', activeTitle:'${title}'})" title="查找带回">选择</a>
						</td>
					</c:if>
				</tr>
			</s:iterator>
		</tbody>
	</table>
	<div class="panelBar">
		<div class="pages">
				<span>显示</span>
				<select class="combox" name="numPerPage" onchange='<s:if test="%{searchType==null||searchType==''}">navTabPageBreak({numPerPage:this.value})</s:if><s:else>dialogPageBreak({numPerPage:this.value})</s:else>'>
					<option value="15" <c:if test="${paginator.pageSize==15}">selected='selected'</c:if> >15</option>
					<option value="30" <c:if test="${paginator.pageSize==30}">selected='selected'</c:if> >30</option>
					<option value="50" <c:if test="${paginator.pageSize==50}">selected='selected'</c:if> >50</option>
					<option value="100" <c:if test="${paginator.pageSize==100}">selected='selected'</c:if> >100</option>
					<option value="200" <c:if test="${paginator.pageSize==200}">selected='selected'</c:if> >200</option>
				</select>
				<span>条，共${paginator.totalCount}条</span>
			</div>
			<div class="pagination" targetType="${(searchType==null||searchType=='')?'navTab':'dialog'}" totalCount="${paginator.totalCount}" 
				numPerPage="${paginator.pageSize}" pageNumShown="10" currentPage="${paginator.pageIndex}"></div>
	</div>
</div>